Skip to content

perf(docker): skip make install, copy vizd binary directly - #98

Merged
On1x merged 2 commits into
masterfrom
ci/skip-make-install
Apr 28, 2026
Merged

On1x merged 2 commits into
masterfrom
ci/skip-make-install

Conversation

@chiliec

@chiliec chiliec commented Apr 28, 2026 •

Copy link
Copy Markdown
Member

Summary

Stack of three perf changes on top of #97. Drops a hidden ~3 min recompile and trims the runtime image footprint by 33%.

Background

PR #97 scoped the build to make -j$(nproc) vizd, which only compiles the daemon binary and skips cli_wallet, util programs, tests, and examples. But the subsequent make install step silently re-triggers CMake's all target, rebuilding everything that step #18 deliberately skipped. Confirmed by inspecting #97's warm-build log of run 25041089256 (#19 elapsed 177s, log shows compilations of appbase_example, chainbase_test, graphene_wallet, etc.).

After fixing that, profiling the warm path showed two more cheap wins around the same Dockerfile area: the multi-stage final COPY brings the entire builder /usr/local (most of which is just the base-image directory tree) and a trailing builder-stage cleanup RUN runs in a stage that's discarded by multi-stage anyway.

Changes

1. Skip make install, copy the binary directly

# before
RUN set -xe ;\
    cd \$APPDIR/build ;\
    make install ;\
    rm -rf \$APPDIR

# after
RUN set -xe ;\
    cp \$APPDIR/build/programs/vizd/vizd /usr/local/bin/vizd

The runtime image only invokes /usr/local/bin/vizd (see share/vizd/vizd.sh). No .so deps from the project's own libs (-DBUILD_SHARED_LIBRARIES=FALSE). The trailing rm -rf \$APPDIR was a no-op anyway because the builder stage is discarded in multi-stage.

2. Tighten the multi-stage final COPY

# before
COPY --from=builder /usr/local /usr/local

# after
COPY --from=builder /usr/local/bin/vizd /usr/local/bin/vizd

Runtime image now contains exactly the binary that gets executed, on top of phusion noble's untouched /usr/local. Smaller layer to push to Docker Hub, smaller graph to export to GHA layer cache.

3. Drop the wasted builder-stage cleanup RUN

The trailing RUN apt-get clean && apt-get autoremove -y && rm -rf ... ran in the builder stage, which is discarded by multi-stage. The accompanying comment claimed the step "removes anything that landed in real layers," but those real layers never reach the runtime image. Dead code.

Measured results

Run `25051281884`, `Dockerfile-production`:

After #97 After #98 commit 1 After #98 commit 2 (A+B) Total Δ
Cold 16m38s 12m43s 13m14s* −3m24s
Warm 4m50s 2m11s 1m27s −3m23s
Warm/cold ratio 0.29 0.17 0.11 —
Image size 148.9 MB 148.9 MB 99.6 MB −49 MB (−33%)

*Cold +31s vs commit 1 is GHA runner variance, not a regression — the layer graph and steps are smaller. Warm run confirms the trend.

Where the A+B savings landed (warm):

Step Before A+B After A+B Δ
`#26` Push to Docker Hub 15.2s 3.0s −12s
`#27` Export to GHA cache 28.3s 12.6s −16s
`#20` Wasted cleanup `RUN` 0.1s (gone) trivial

Cumulative result vs the original baseline (no caching, every PR cold ~20-40 min): warm path went from ~30 min to 1m27s — over 20× faster.

What does `make install` install that we're now skipping?

The CMake `install` target writes these to `/usr/local/bin` (and headers under `/usr/local/include`):

  • `cli_wallet`, `get_dev_key`, `sign_digest`, `sign_transaction`, `test_block_log`
  • `js_operation_serializer`, `size_checker`
  • All `graphene_*` library headers

None are referenced by the runtime image. The Docker images don't ship `cli_wallet` (it wasn't useful inside a daemon container). For local development, `make install` on the host build still works as before — this PR only affects the Dockerfile RUN steps.

Maintenance note

If a future change adds a runtime artifact that the Docker image needs (e.g. a helper binary), the explicit `cp` line and the multi-stage `COPY` need to be extended. The trade is: a small hand-maintained list (visible at a glance in the Dockerfile) for a faster build and a slimmer image on every CI run.

Validation

All checks performed against the pushed `vizblockchain/vizd:ci-skip-make-install` image (linux/amd64) using the Docker Hub registry API — no docker daemon required:

  • Cold build measured under master cache scope: 13m14s
  • Warm rerun measured: 1m27s, ratio 0.11
  • Image-content audit: the multi-stage layer contains exactly `usr/local/bin/vizd` and parent dirs — no buildtime cruft, headers, or other binaries
  • Binary integrity: `vizd` is a 32 MB ELF 64-bit PIE executable, x86-64, with debug_info, BuildID present
  • Runtime dependencies: only `libc.so.6`, `libm.so.6`, `libgcc_s.so.1`, `libstdc++.so.6` — all shipped by `phusion/baseimage:noble-1.0.3`, so no missing-shared-library failure mode is possible from the multi-stage tightening
  • Image size: 99.59 MB compressed vs 148.90 MB for `vizblockchain/vizd:latest` (current production) — 33% smaller

The "actually exec the binary" smoke test would need a docker daemon, but with the static analysis above (binary is a valid ELF, all dynamic deps are present in the base image, the binary contains expected vizd config strings), the residual risk is essentially zero.

🤖 Generated with Claude Code

@chiliec
chiliec changed the base branch from ci/build-time-reduction to master April 28, 2026 11:52
chiliec added 2 commits April 28, 2026 14:52
`make install` triggers CMake's install-depends-on-all rule, which
rebuilds every target in the build graph (cli_wallet, util programs,
graphene_wallet, appbase_example, chainbase_test) — including the
ones we deliberately skipped via `make -j$(nproc) vizd` in the prior
step. Measured cost on warm path: ~3 minutes of redundant compile.

The runtime image only invokes /usr/local/bin/vizd (see
share/vizd/vizd.sh), so we copy the single binary directly. The
multi-stage final image still starts from a clean base, so nothing
in /usr/local except vizd matters.

Drops the trailing `rm -rf $APPDIR` because the builder stage is
discarded in multi-stage; the rm contributed nothing but I/O.

Expected impact on PR-warm path:
  - before: 4m50s (build #18 ~24s + make install #19 ~177s + push)
  - after:  ~1m45s (build #18 ~24s + cp ~0s + push)

Cold path saves the same ~3 min for the same reason.
Two related image-trimming changes:

1) Multi-stage final COPY only brings the vizd binary, not the
   entire builder /usr/local. The runtime image only invokes
   /usr/local/bin/vizd (see share/vizd/vizd.sh) and the static link
   (-DBUILD_SHARED_LIBRARIES=FALSE) means no .so dependencies. The
   tighter COPY shrinks the runtime layer and the graph exported to
   GHA layer cache.

2) Drop the trailing builder-stage cleanup RUN (apt-get clean +
   autoremove + rm -rf). The accompanying comment claimed the step
   "removes anything that landed in real layers," but the entire
   builder stage is discarded by multi-stage build — its real layers
   never reach the runtime image. The step was dead code.

Both changes preserve runtime behavior and reduce per-build work.
@chiliec
chiliec force-pushed the ci/skip-make-install branch from 822ec91 to f9463f4 Compare April 28, 2026 11:54
@chiliec
chiliec marked this pull request as ready for review April 28, 2026 12:21
@On1x
On1x merged commit 36b0aa8 into master Apr 28, 2026
2 checks passed
@chiliec
chiliec deleted the ci/skip-make-install branch April 28, 2026 14:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants